<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SSE Example</title>
</head>

<body>
    <h1>Server-Sent Events Example</h1>
    <div id="messages"></div>

    <script>
        // 创建 EventSource 对象，连接到 /events 路径
        const eventSource = new EventSource('http://127.0.0.1:8888/chat/test');


        eventSource.onmessage = function (event) {
            console.log("收到数据:", event.data);
        };

        eventSource.onerror = function (event) {
            console.error("SSE 发生错误", event);
        };

    </script>
</body>

</html>